package com.project_test.kun.travelling_1st.GoodsDetailActivities.HouseDetail;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.project_test.kun.travelling_1st.HomePage.category.facility_HPHouseDetail;
import com.project_test.kun.travelling_1st.R;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by asus on 2016/10/17 09 49.
 * 邮箱:763433963@qq.com
 */
public class PopupWindowAdapter extends BaseAdapter {
    private Context mContext;
    private List<facility_HPHouseDetail> data;
    private ViewHolder mHolder;

    public PopupWindowAdapter(Context context, List<facility_HPHouseDetail> data) {
        mContext = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data!=null?data.size():0;
    }

    @Override
    public facility_HPHouseDetail getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view==null){
            view= LayoutInflater.from(mContext).inflate(R.layout.item_grid_popupwindow,viewGroup,false);
            mHolder = new ViewHolder();
            mHolder.Image= (ImageView) view.findViewById(R.id.image_item_grid_pp);
            mHolder.text= (TextView) view.findViewById(R.id.text_item_grid_pp);
            view.setTag(mHolder);
        }else{
            mHolder= (ViewHolder) view.getTag();
        }
        //赋值
        facility_HPHouseDetail detail = data.get(i);
        mHolder.text.setText(detail.getName());
        Picasso.with(mContext).load(detail.getIcon()).into(mHolder.Image);
        return view;
    }
    static class ViewHolder{
        public ImageView Image;
        public TextView text;

    }
}
